#ifndef __BUOLA_GUI_X11_CFIXESREGION_H__
#define __BUOLA_GUI_X11_CFIXESREGION_H__

#include <buola/gui/x11/auto.h>
#include <X11/Xlib.h>

namespace buola { namespace gui { namespace x11 {

class CFixesRegion
{
public:
    CFixesRegion();
    CFixesRegion(const CRect_d &pRect);
    CFixesRegion(const CFixesRegion &pRegion);
    CFixesRegion(CPixmap*,const CPoint_d &pOffset=CPoint_d(nZero));
    CFixesRegion(Window pWindow,const CPoint_d &pOffset); //from window ID
    CFixesRegion(TID);
    ~CFixesRegion();

    void CreateVoid();

    void Subtract(const CRect_d &pRect);
    void Add(const CRect_d &pRect);
    void Intersect(const CRect_d &pRect);

    void Subtract(const CFixesRegion &pRegion);
    void Add(const CFixesRegion &pRegion);
    void Intersect(const CFixesRegion &pRegion);

    void Clear();

    void Set(TID);
    void Copy(const CFixesRegion &pRegion);
    void Copy(const CRect_d &pRect);
    void Copy(CPixmap*,const CPoint_d &pOffset=CPoint_d(nZero));
    void Copy(Window,const CPoint_d &pOffset=CPoint_d(nZero));

    void Translate(const CPoint_d &pPoint);

    CFixesRegion &operator=(const CFixesRegion &pRegion);
    CFixesRegion &operator=(const CRect_d &pRect);
    CFixesRegion &operator-=(const CRect_d &pRect);
    CFixesRegion &operator+=(const CRect_d &pRect);
    CFixesRegion &operator*=(const CRect_d &pRect);
    CFixesRegion &operator-=(const CFixesRegion &pRegion);
    CFixesRegion &operator+=(const CFixesRegion &pRegion);
    CFixesRegion &operator*=(const CFixesRegion &pRegion);
    CFixesRegion operator-(const CFixesRegion &pOther) const;
    CFixesRegion operator+(const CFixesRegion &pOther) const;
    CFixesRegion operator*(const CFixesRegion &pOther) const;
    CFixesRegion operator-(const CRect_d &pOther) const;
    CFixesRegion operator+(const CRect_d &pOther) const;
    CFixesRegion operator*(const CRect_d &pOther) const;

    TID GetID() const           {   return mID;     }

    void Print(io::CTextWriter&) const;
    void GetRects(std::vector<CRect_d>&pRects) const;

private:
    TID mID;

public:
    static const CFixesRegion mNull;
};

inline io::CTextWriter &operator<<(io::CTextWriter &pWriter,const CFixesRegion &pRegion)
{
    pRegion.Print(pWriter);
    return pWriter;
}

/*namespace x11*/ } /*namespace gui*/ } /*namespace buola*/ }

#endif
